;+
; NAME:
;       TEMP_DEPENDENT_VARIABLES
;
; PURPOSE:
;       Subroutine to calculate the temperature-dependent variables in
;       the IRDC modeling scheme (tau, f_data, sig_f).
;
; CATEGORY:
;       IRDC modeling
;
; CALLING SEQUENCE:
;       TEMP_DEPENDENT_VARIABLES, Td [,OBJNO=i]
;
; INPUTS:
;       Td    -- Dust temperature
;
; OPTIONAL INPUTS:
;       OBJNO -- Object number(s) (array element(s) from rb3) to
;                calculate for.  May be scalar or vector.
;
; KEYWORD PARAMETERS:
;       NONE
;
; OUTPUTS:
;       Places current values of these variables in the FFORE_BLOCK
;       common block.
;
; OPTIONAL OUTPUTS:
;       NONE
;
; COMMON BLOCKS:
;       FFORE_BLOCK
;
; MODIFICATION HISTORY:
;
;       Created:  05/04/11, TPEB -- Initial version, code block
;                                   removed from model_ffore.pro
;                                   because of need in the new
;                                   temperature-fitting scheme.
;       Modified: 05/17/11, TPEB -- Added optional input OBJNO to
;                                   calculate quantities for ONLY the
;                                   object(s) of interest (to speed up
;                                   calculation in the temp-fitting
;                                   scheme).
;       Modified: 07/22/11, TPEB -- Added keyword BGPS to select for
;                                   BGPS values.
;       Modified: 09/08/11, TPEB -- Changed GAMMA calculation to
;                                   FLUX2TAU_BGPS for /BGPS flag.
;       Modified: 12/09/11, TPEB -- Remove all options for "old"
;                                   version (i.e. use with Rathborne
;                                   et al. 2006 sources).
;
;-

PRO TEMP_DEPENDENT_VARIABLES, Td, OBJNO=i
  
  COMMON FFORE_BLOCK
  
  ;; If no OBJNO selected, then do all!
  IF n_elements(i) EQ 0 THEN i = lindgen(n)
  
  gamma = FLUX2TAU_BGPS(Td, /mJy, /apper)
  
  ;; Calculate tau, f_data
  tau[i]    = gamma * rb3[i].s_peak
  f_data[i] = 1.d - (rb3[i].c_meas / (1.d - exp(-tau[i])))
  
  ;; Send requisite info to get sig_f
  sig_f[i]  = sqrt( FDATA_VARIANCE_BGPS(tau[i], gamma, rb3[i].c_meas, $
                                        rb3[i].sig_c, rb3[i].s_err) )
  
  RETURN
END
